<!DOCTYPE html>
<meta charset="UTF-8">
<h2>JSONP 数据</h2>
<div style="margin: 10px 0; width: 200px;">
	<input data-type="combobox" style="width: 250px"
		data-define="
				loader: myloader,
				mode: 'remote',
				valueField: 'id',
				textField: 'name',width:200
			">
</div>
<script>
	var myloader = function(param, success, error) {
	    var q = param.q || '';
	    if (q.length <= 1) {
		    return false
	    }
	    $.ajax({
	        url : 'http://.../searchJSON',
	        dataType : 'jsonp',
	        data : {
	            featureClass : "P",
	            style : "full",
	            maxRows : 20,
	            name_startsWith : q
	        },
	        success : function(data) {
		        var items = $.map(data.geonames, function(item) {
			        return {
			            id : item.geonameId,
			            name : item.name + (item.adminName1 ? ', ' + item.adminName1 : '') + ', ' + item.countryName
			        };
		        });
		        success(items);
	        },
	        error : function() {
		        error.apply(this, arguments);
	        }
	    });
    }
</script>
